home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20031118-20041115 / 000400_dm_v_2000@yahoo.com_Wed Sep 22 13:15:12 2004.msg < prev    next >
Internet Message Format  |  2020-01-01  |  6KB

  1. Path: newsmaster.cc.columbia.edu!newsfeed1.nycmny01.us.to.verio.net!newspeer1.stngva01.us.to.verio.net!verio!newsfeed.vmunix.org!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnews1.google.com!not-for-mail
  2. From: dm_v_2000@yahoo.com (Peter V.)
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: Return codes and If statments
  5. Date: 22 Sep 2004 09:53:34 -0700
  6. Organization: http://groups.google.com
  7. Lines: 171
  8. Message-ID: <3f9c05b0.0409220853.25e5bd46@posting.google.com>
  9. References: <3f9c05b0.0409211252.5aa51cb1@posting.google.com>   <slrncl18i5.56s.fdc@sesame.cc.columbia.edu> <1095827419.338981.28270@k26g2000oda.googlegroups.com>
  10. NNTP-Posting-Host: 206.6.159.100
  11. Content-Type: text/plain; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Trace: posting.google.com 1095872014 30819 127.0.0.1 (22 Sep 2004 16:53:34 GMT)
  14. X-Complaints-To: groups-abuse@google.com
  15. NNTP-Posting-Date: Wed, 22 Sep 2004 16:53:34 +0000 (UTC)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15178
  17.  
  18. Frank and Mark,
  19.  
  20.   thank you both for your advice.  I am sticking to recommended format
  21. Number 2, and that seems to have done the trick.
  22.  
  23.  Once again, thanks.
  24.  
  25. Peter Vasseur
  26.  
  27. "Mark Sapiro" <slash_dev_slash_null_2000@yahoo.com> wrote in message news:<1095827419.338981.28270@k26g2000oda.googlegroups.com>...
  28. > Frank da Cruz wrote:
  29. > > On 2004-09-21, Peter V. <dm_v_2000@yahoo.com> wrote:
  30. > > : I am modifying a C-Kermit script I have to not continue processing
  31. > > : if a call to another script does not return a value of 1 (We are
  32. >  doing
  33. > > : this for fail over testing).
  34. > > :
  35. > > : Here is the C-Kermit code in question:
  36. > > :
  37. > > : # run the db_status script in the CRON directory
  38. > > : run db_status
  39. > > :
  40. > > : # See if the ret value is != 1
  41. > > : #  If it != 1 tell user we are not on the primay server and then
  42. > > : exit).
  43. > > :
  44. > > : if != \v(pexitstat) 1
  45. > > :  {
  46. > > :    echo Return code != 1 ... Not the primary server
  47. > > :    echo return code =  \v(pexitstat)
  48. > > :    exit
  49. > > :
  50. > > :   }
  51. > > : # otherwise we are on the primary server so continue processing
  52. > > : ...
  53. > > : ...
  54. > > : ...
  55. > > :
  56. > > : When I run this on the Secondary server it works (since the result
  57. > > : returned from the db_status script is a 2 since it is not the
  58. >  primary
  59. > > : server).
  60. > > :
  61. > > : However, when I test this on the primay server the code exits
  62. >  (meaning
  63. > > : it executes the body of the if statment above) despite the fact
  64. >  that
  65. > > : the return code from db_status is 1.
  66. > > :
  67. > > : Any suggestions, as to what I'm doing wrong?
  68. > > :
  69. > > My first suggestion is to use the recommended format for grouping
  70. >  statements:
  71. > >
  72. > >   if != \v(pexitstat) 1 {
  73. > >       echo Return code != 1 ... Not the primary server
  74. > >       echo return code =  \v(pexitstat)
  75. > >       exit
  76. > >   }
  77. > >
  78. > > If that doesn't help, then check to see what the subprocess actually
  79. > > returns as its exit code (OK, you say it is 1 but...).  If so, then
  80. >  make sure
  81. > > you are running the current version of C-Kermit, which is 8.0.211.
  82. >  If you
  83. > > are, then we're in for some debugging; contact
  84. >  kermit-support@columbia.edu.
  85. > >
  86. > > - Frank
  87. > Frank's suggestion will help. This is another case of if { } else { }
  88. > constructs that only work if written in certain ways.
  89. > I've mentioned this before, but the document
  90. > http://www.columbia.edu/kermit/ckermit70.html
  91. > contains several examples of if/else coding in section 7.20.1. The
  92. > first four of these are
  93. > Example 1:
  94. > IF condition { command1, command2 } ELSE { command3, command4 }
  95. > Example 2 (same as Example 1):
  96. > IF condition {
  97. > command1
  98. > command2
  99. > } ELSE {
  100. > command3
  101. > command4
  102. > }
  103. > Example 3 (same as 1 and 2):
  104. > IF condition {
  105. > command1
  106. > command2
  107. > }
  108. > ELSE { command3, command4 }
  109. > Example 4 (same as 1-3):
  110. > IF condition {
  111. > command1
  112. > command2
  113. > }
  114. > ELSE {
  115. > command3
  116. > command4
  117. > }
  118. > In examples 3 and 4, various problems occur in execution of the ELSE
  119. > clause when the condition is false. This change happened somewhere
  120. > between 8.0.201 and 8.0.206 due to changes in the handling of
  121. > "immediate macros". This is illustrated by the following.
  122. > fog: {14} $ cat kt3
  123. > # Example 1:
  124. > IF false { .theday := \v(day), show macro theday } ELSE { .thedate :=
  125. > \v(date), show macro thedate }
  126. > # Example 2 (same as Example 1):
  127. > IF false {
  128. > .theday := \v(day)
  129. > show macro theday
  130. > } ELSE {
  131. > .thedate := \v(date)
  132. > show macro thedate
  133. > }
  134. > # Example 3 (same as 1 and 2):
  135. > IF false {
  136. > .theday := \v(day)
  137. > show macro theday
  138. > }
  139. > ELSE { .thedate := \v(date), show macro thedate }
  140. > # Example 4 (same as 1-3):
  141. > IF false {
  142. > .theday := \v(day)
  143. > show macro theday
  144. > }
  145. > ELSE {
  146. > .thedate := \v(date)
  147. > show macro thedate
  148. > }
  149. > fog: {15} $ kermit
  150. > Executing /home_mo/msapiro/.kermrc for UNIX...
  151. > Executing /home_mo/msapiro/.mykermrc...
  152. > Good Evening.
  153. > C-Kermit 8.0.212 Dev.00, 10 May 2004, for HP-UX 11.00
  154. > Copyright (C) 1985, 2004,
  155. > Trustees of Columbia University in the City of New York.
  156. > Type ? or HELP for help.
  157. > (/home_mo/msapiro/) C-Kermit>take kt3
  158. > thedate = 21 Sep 2004
  159. > thedate = 21 Sep 2004
  160. > thedate = \v(date)
  161. > thedate = \v(date)
  162. > (/home_mo/msapiro/) C-Kermit>
  163. > I have trained myself to always code if/else in the "recommended
  164. > format", but it would be nice if the examples that no longer work were
  165. > removed from the documentation.